﻿using System;
using System.Web.UI.WebControls;
using OpenWaves.ActivityFeed;
using OpenWaves.ActivityFeed.RavenDB;

namespace OpenWaves.ActivityFeed.Web.Tests.Samples
{
    public partial class SampleUpdateContentTemplates : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void AddContent(object sender, EventArgs e)
        {
            UpdateContent updateContent = null;

            var contentType = ((Button) sender).CommandArgument;
            switch (contentType)
            {
                case "contentA":
                    updateContent = new ContentA();
                    break;
                case "contentB":
                    updateContent = new ContentB();
                    break;
                case "contentC":
                    updateContent = new ContentC();
                    break;
                default:
                    updateContent = new ContentUnknown();
                    break;
            }

            using (var session = ActivityFeedDocumentStore.Current.OpenSession())
            {
                var service = new ActivityFeedService(session);
                service.PublishPublicUpdate(updateContent, "user1", "web", Topic.FromUserId("user1"));
                session.SaveChanges();
            }
        }
    }

    public class ContentA: UpdateContent{}

    public class ContentB : UpdateContent { }

    public class ContentC : UpdateContent { }

    public class ContentUnknown : UpdateContent { }
} 